package com.osmap.openstreetmap.adapter;

import java.util.List;

import android.app.Activity;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;

public class WheelPagerAdapter extends PagerAdapter {

	private Activity context;
	private List<View> pageViews;

	public WheelPagerAdapter(Activity context, List<View> pageViews) {
		this.context = context;
		this.pageViews = pageViews;
	}

	@Override
	public int getCount() {
		return pageViews.size();
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		return arg0 == arg1;
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		container.removeView(pageViews.get(position));
	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		View view = pageViews.get(position);
		try {
			((ViewPager) container).addView(view);
		} catch (Exception e) {
		}

		return view;
	}

}
